package com.javajun.endofterm.service;

import com.javajun.endofterm.common.CommonService;
import com.javajun.endofterm.entity.ExpressDelivery;
import com.javajun.endofterm.repository.ExpressDeliveryRepository;
import com.javajun.endofterm.repository.StudentRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * Author: Xiong Limin
 * Date: 2020-12-03-11:32 下午
 */
@Service
public class ExpressDeliveryService extends CommonService<ExpressDelivery, Integer> {
    @Autowired
    private ExpressDeliveryRepository expressDeliveryRepository;

    @Autowired
    private StudentRepository studentRepository;

    public long getNotPickUpCount() {
        return expressDeliveryRepository.countByWhetherPickUp(0);
    }

    public Page<ExpressDelivery> findByDomitoryId(Pageable pageable, Integer domiId) {
        return expressDeliveryRepository.findByDomitoryId(pageable, domiId);
    }

    public int getDomitoryNotPickUpExpress(int domiId) {
        return  expressDeliveryRepository.countByWhetherPickUpAndDomitoryId(0, domiId);
    }

    public int getDomitoryAllExpress(int domiId) {
        return expressDeliveryRepository.countByDomitoryId(domiId);
    }
}
